using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NQueries.TestSupport;
using NQueries.Utils;

namespace NQueries.Data.Test.Utils
{
    [TestClass]
    public class CheckTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void ElementCountInRangeFailedTest()
        {
            const int MIN = 1;
            const int MAX = 3;
            TestTools.AssertThrows<ArgumentOutOfRangeException>(() => Check.ElementCountInRange(new string[0], MIN, MAX, "test"));
            TestTools.AssertThrows<ArgumentOutOfRangeException>(() => Check.ElementCountInRange(new string[4], MIN, MAX, "test"));
        }

        [TestMethod]
        public void ElementCountInRangeTest()
        {
            const int MIN = 1;
            const int MAX = 3;
            Check.ElementCountInRange(new string[2], MIN, MAX, "test");
        }

        [TestMethod]
        public void IsNotNullFailedTest() { TestTools.AssertThrows<ArgumentNullException>(() => Check.IsNotNull(null, string.Empty)); }

        [TestMethod]
        public void IsNotNullOrEmptyFailedTest()
        {
            TestTools.AssertThrows<ArgumentNullException>(() => Check.IsNotNullOrEmpty(null, "test"));
            TestTools.AssertThrows<ArgumentNullException>(() => Check.IsNotNullOrEmpty(string.Empty, "test"));
        }

        [TestMethod]
        public void IsNotNullOrEmptyTest() { Check.IsNotNullOrEmpty("test", "test"); }

        [TestMethod]
        public void IsNotNullTest() { Check.IsNotNull(new object(), string.Empty); }

        [TestMethod]
        public void IsOfTypeFailedTest()
        {
            TestTools.AssertThrows<ArgumentNullException>(() => Check.IsOfType(null, typeof(ITest), "test"));
            TestTools.AssertThrows<ArgumentNullException>(() => Check.IsOfType(new Test(), null, "test"));
            TestTools.AssertThrows<ArgumentException>(() => Check.IsOfType(string.Empty, typeof(ITest), "test"));
        }

        [TestMethod]
        public void IsOfTypeTest() { Check.IsOfType(new Test(), typeof(ITest), "test"); }

        #region Nested type: ITest

        interface ITest {}

        #endregion

        #region Nested type: Test

        class Test : ITest {}

        #endregion
    }
}